package com.laborer.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.laborer.entity.User;
import com.laborer.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Auther: Wangym
 * @Date: 2021/6/11 22:49
 * @Description:
 */
@Controller
@RequestMapping("/home")
public class HomeController {
    private final String PREFIX = "home";
    @Autowired
    private IUserService iUserService;
    @RequestMapping("")
    public String home(String userName, Model model){
        QueryWrapper<User> queryUser=new QueryWrapper<>();
        queryUser.eq("user_name",userName);
        List<User> list = iUserService.list(queryUser);
        User user = list.get(0);
        model.addAttribute("user",user);
        model.addAttribute("userName",userName);
        return PREFIX + "/home";
    }
}
